import os

import pandas as pd

df1 = pd.DataFrame([["Tom", 18, "football", "beijing"],
                    ["Marry", 19, "swim", "nanjing"],
                    ["Luse", 20, "study", "tianjing"]]
                   , columns=['name', 'age', 'enjoy', 'city'], index=list("abc"))
# print(df1)
filename = 'data2.xlsx'
if os.path.exists(filename):
    os.remove(filename)
writer = pd.ExcelWriter(filename)
data = list(range(4))
df2 = pd.DataFrame(data, columns=['name', 'age', 'enjoy', 'city'], index=list("abc"))
df2.to_excel(excel_writer=writer, sheet_name='sheet_2')
df1.to_excel(excel_writer=writer, sheet_name='sheet_3')
writer.save()
writer.close()
print(df2)
